/*
 * Copyright (C) 2009 Leandro de Oliveira Aparecido <lehphyro@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.japa.annotation;

import java.lang.annotation.*;

/**
 * Indicates that the return value of the annotated method must be replaced by the result of some
 * JPA query.
 * 
 * @author Leandro Aparecido
 * @since 1.0
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
public @interface RepositoryReturn {
	/**
	 * Equivalent to <code>name</code>, it is just for convenience when you need to set only
	 * the named query to be used.
	 * <p>Either this or <code>name</code> is required.
	 */
	String value() default "";
	
	/**
	 * Name of the JPA named-query.
	 * <p>Either this or <code>value</code> is required.
	 */
	String name() default "";
	
	/**
	 * Argument names of the method if your classes have not been compiled in debug mode.
	 */
	String argNames() default "";

	/**
	 * Exception to be thrown if the JPA query returns an empty list.
	 * <p>Defaults to {@link com.google.code.japa.annotation.IgnoreEmptyResultException}
	 * indicating that no exception should be thrown.
	 */
	Class<? extends Throwable> empty() default IgnoreEmptyResultException.class;
}
